import timefn from '@/z/callback/timefn'
import store from '@/store'
let searchjson = [
  { label: '用户名', value: 'uUser' },
  {
    label: '时间选择',
    value: 'time',
    values: ['sjs', 'sje'],
    type: 'datetimerange',
    defaultValue: [
      Number(new Date(`${timefn.gettime(0)} 00:00:00`)),
      Number(new Date()),
    ],
    shortcuts: [
      {
        text: '今日',
        value: [
          Number(new Date(`${timefn.gettime(0)} 00:00:00`)),
          Number(new Date(`${timefn.gettime(-1)} 00:00:00`)),
        ],
      },
      {
        text: '本月',
        value: [
          Number(new Date(`${timefn.gettimemm(0)} 00:00:00`)),
          Number(new Date(`${timefn.gettimemm(-1)} 00:00:00`)),
        ],
      },
      {
        text: '上月',
        value: [
          Number(new Date(`${timefn.gettimemm(1)} 00:00:00`)),
          Number(new Date(`${timefn.gettimemm(0)} 00:00:00`)),
        ],
      },
      {
        text: '全部',
        value: [
          Number(new Date(`2020/09/01 00:00:00`)),
          Number(new Date(`${timefn.gettimemm(-1)} 00:00:00`)),
        ],
      },
    ],
  },
]
let tablejson = [
  { label: '订单号', value: 'ddh' },
  { label: '充值时间', value: 'sjzfc' },
  {
    tablecallback: (datas = []) => {
      let jez = 0
      datas.forEach((e) => {
        jez += Number(e.je)
      })
      jez = jez / 100
      return [{ label: `金额(${jez})`, value: 'je', fl: 100 }]
    },
  },
]

// 订单号	充值时间	支付类型	金额(1)
// sjc
let exceldata = [
  { label: '订单号', value: 'ddh' },
  { label: '充值时间', value: 'sjzfc' },
  {
    tablecallback: (datas = []) => {
      let jez = 0
      datas.forEach((e) => {
        jez += Number(e.je)
      })
      jez = jez / 100
      return [{ label: `金额(${jez})`, value: 'je', fl: 100 }]
    },
  },
]
let edtjson = [
  { label: '订单号', value: 'ddh' },
  { label: '充值时间', value: 'sjzfc' },
  {
    label: '支付类型',
    value: 'type',
    type: 'select',
    option: [
      { label: '微信支付', value: '0' },
      { label: '支付宝支付', value: '1' },
    ],
  },
  { label: '金额', value: 'je', fl: '100' },
  {
    callbackasync: async (data) => {
      let USearch = await store.dispatch('usearch/getUSearch', {
        uUser: data.uUser,
      })
      if (USearch.length == 0) {
        return []
      }
      let r = []
      r.push(
        { label: '用户名', value: 'uUser' },
        { label: '时间', value: 'USearchsjc', defaultValue: USearch[0].sjc },
        {
          label: '用户昵称',
          value: 'USearchwxnc',
          defaultValue:
            USearch[0].utype == 7 || USearch[0].utype == 8
              ? USearch[0].printid
              : USearch[0].wxnc,
        },
        {
          label: '用户类型',
          value: 'USearchutype',
          type: 'select',
          option: [
            { label: '微信用户', value: 5 },
            { label: '支付宝用户', value: 6 },
            { label: '刷卡用户', value: 7 },
            { label: '次卡用户', value: 8 },
          ],
        },
        {
          label: '用户头像',
          value: 'wxpic',
          type: 'img',
          defaultValue: USearch[0].wxpic,
        }
      )
      return r
    },
  },
]
edtjson.forEach((e) => {
  e.readonly = 'readonly'
})
export default { searchjson, tablejson, exceldata, edtjson }
